package cn.mumzone.pos.ui.widgets;

import android.content.Context;
import android.support.constraint.ConstraintLayout;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.mumzone.pos.R;

/**
 * Created by qiuzhenhuan on 2019/7/4.
 */

public class StepView extends LinearLayout {

    @BindView(R.id.iv_progress_one)
    ImageView ivProgressOne;
    @BindView(R.id.iv_progress_two)
    ImageView ivProgressTwo;
    @BindView(R.id.iv_progress_three)
    ImageView ivProgressThree;

    @BindView(R.id.view_line_one)
    View viewLineOne;
    @BindView(R.id.view_line_two_left)
    View viewLineTwoLeft;
    @BindView(R.id.view_line_two_right)
    View viewLineTwoRight;
    @BindView(R.id.view_line_three)
    View viewLineThree;

    @BindView(R.id.tv_progress_one)
    TextView tvProgressOne;
    @BindView(R.id.tv_progress_two)
    TextView tvProgressTwo;
    @BindView(R.id.tv_progress_three)
    TextView tvProgressThree;

    private int mCurrPosition = 0;

    public int getCurrPosition() {
        return mCurrPosition;
    }

    public StepView(Context context) {
        this(context,null);
    }

    public StepView(Context context, AttributeSet attrs) {
        this(context, attrs,-1);
    }

    public StepView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        View contentView = LayoutInflater.from(context).inflate(R.layout.view_step_view,this,true);
        ButterKnife.bind(this,contentView);
    }

    public void setProgressText(String progressOne,String progressTwo,String progressThree){
        tvProgressOne.setText(progressOne);
        tvProgressTwo.setText(progressTwo);
        tvProgressThree.setText(progressThree);
    }


    public void setCurrentPosition(int position){
        mCurrPosition = position;
        viewLineThree.setBackgroundResource(R.color.order_status_close);
        ivProgressThree.setImageResource(R.drawable.svg_ic_progress_un_complete);
        if(position == 0){
            ivProgressOne.setImageResource(R.drawable.svg_ic_progress_progressing);
            viewLineOne.setBackgroundResource(R.color.order_status_service);

            ivProgressTwo.setImageResource(R.drawable.svg_ic_progress_un_complete);
            viewLineTwoLeft.setBackgroundResource(R.color.order_status_close);
            viewLineTwoRight.setBackgroundResource(R.color.order_status_close);
        }else {
            ivProgressOne.setImageResource(R.drawable.svg_ic_progress_completed);
            viewLineOne.setBackgroundResource(R.color.order_status_reserve);

            ivProgressTwo.setImageResource(R.drawable.svg_ic_progress_progressing);
            viewLineTwoLeft.setBackgroundResource(R.color.order_status_service);
            viewLineTwoRight.setBackgroundResource(R.color.order_status_service);
        }
    }
}
